// throttle
function throttle(fn, delay) {
  let timer
  delay = delay || 500
  return function() {
    if(timer){
      return
    }
    timer = setTimeout(() => {
      fn.call(this, arguments)
      timer = null
    }, delay)
  }
}